package org.chen.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertiesUtils {

	/**
	 * @param path
	 *            配置文件路径
	 */
	public static Properties loadPropertis(String path) {
		Properties props = null;
		try {
			InputStream in = PropertiesUtils.class.getClassLoader().getResourceAsStream(path);
			props = new Properties();
			props.load(in);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return props;
	}

	/**
	 * @param path
	 *            配置文件路径
	 * @param pkey
	 *            配置文件中的键
	 * @return 通过键获取值
	 */
	public static String getPropByKey(String path, String pkey) {
		Properties props = loadPropertis(path);
		String propValue = props.getProperty(pkey);
		return propValue;
	}

}
